package com.eschool.beans;

import java.util.Date;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;

import com.eschool.model.Session;
import com.eschool.service.SchoolManagementService;
import com.eschool.service.impl.SchoolManagementServiceImpl;

@ManagedBean(name="sessionBean")
@ViewScoped
public class SessionBean {
	
	Session session = new Session();

	public Session getSession() {
		return session;
	}

	public void setSession(Session session) {
		this.session = session;
	}

	SchoolManagementService service = new SchoolManagementServiceImpl();
	
	public String performAction()
	{
		String message;
		
		if(service.addSession(session)) {
			message = "Session Successfully Added";
			FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO,"Info Message", message));
		}
		else {
			message = "Session Not Added";
			FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,"Error Message", message));
		}
		
		return "AddSession";
	}

}
